app.controller('BusShiftTplUpdateCtrl', function ($scope, $modalInstance, toaster, param) {

	$scope.param = param;
	if ($scope.param.data == null) $scope.param.data = {};

	$scope.list = $scope.param.list;
	$scope.tickets = $scope.param.tickets;
	$scope.currentTickets = $scope.param.currentTickets;
	$scope.flag = $scope.tickets < $scope.currentTickets;

	$scope.ids = [];
	$scope.checks = false;//默认未选中
	$scope.ckAll = false;//默认未选中
	$scope.choseArr = [];

	/*单选*/
	$scope.check = function (val) {
		if ($scope.ids.indexOf(val) < 0) {
			$scope.ids.push(val);
		} else {
			$scope.ids.splice($scope.ids.indexOf(val), 1);
		}
	};

	/*全选*/
	$scope.checkAll = function (c, v) {
		if (c == true) {
			$scope.checks = true;
			$scope.choseArr = v;
			//添加所选Id
			for (var i = 0; i < $scope.choseArr.length; i++) {
				$scope.ids.push($scope.choseArr[i].id);
			}
		} else {
			$scope.checks = false;
			$scope.ids = [];
		}
	};

	$scope.ok = function () {
		if ($scope.myForm.$valid) $modalInstance.close($scope.ids);
	};

	$scope.cancel = function () {
		$modalInstance.dismiss('cancel');
	};
});